package org.ben.domain.compositepattern;

import java.util.ArrayList;
import java.util.List;

public class DirectoryComposite extends Directory {
    private List<Directory> directory = new ArrayList<Directory>();

    @Override
    public void listFiles() {
        System.out.println("composite directory...");
        for(Directory d : directory) {
                d.listFiles();
        }
    }

    public List<Directory> getDirectory() {
        return directory;
    }

    public void setDirectory(List<Directory> directory) {
        this.directory = directory;
    }

    public DirectoryComposite addDirectory(Directory d) {
        this.directory.add(d);
        return this;
    }
}
